package com.one.blocks.mvc.exception;

import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 404可测试该配置是否生效
 *
 * @author <a href="mailto:idler41@163.con">linfuxin</a> created on 2023-12-09 14:27:09
 */
public class JsonViewResolver implements ErrorViewResolver {

    @Override
    public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
        return new ModelAndView(new JsonView(request, status, model));
    }
}
